/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sopra09.lv6659438.controller.eintragErfassen;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.actions.LookupDispatchAction;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import java.util.*;

/**
 * Leitet je nach gewähltem Typ weiter an Zeitschrift- oder Buch-Erfassen und
 * initialisiert die Aktionen.
 * @author TJ
 */
public class TypAuswaehlenLDA extends LookupDispatchAction {
    
    /* forward name="success" path="" */
    private final static String BUCH = "Buch";
    private final static String ZEITSCHRIFT = "Zeitschrift";
    
    /** Provides the mapping from resource key to method name.
     * @return Resource key / method name map.
     */
    protected Map getKeyMethodMap() {
      Map map = new HashMap();
      map.put("typbutton.buch", "buchErfassenInitialisieren");
      map.put("typbutton.zeitschrift", "zeitschriftEingebenInitialisieren");
      return map;
    }
    
    /** Action called on typbutton.buch
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @throws java.lang.Exception
     * @return ActionForward
     */
    public ActionForward buchErfassenInitialisieren(ActionMapping mapping,
          ActionForm form,
          HttpServletRequest request,
          HttpServletResponse response) throws java.lang.Exception {

      log.warn("buchErfassenInitialisieren(...) beginnt");

      request.getSession().setAttribute("AWF", "Literatureintrag erfassen");
      request.getSession().setAttribute("AA", "Buch erfassen");
      
      return mapping.findForward(BUCH);
    }
    
    /** Action called on typbutton.zeitschrift
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @throws java.lang.Exception
     * @return ActionForward
     */
    public ActionForward zeitschriftEingebenInitialisieren(ActionMapping mapping,
          ActionForm form,
          HttpServletRequest request,
          HttpServletResponse response) {

      log.warn("zeitschriftEingebenInitialisieren(...) beginnt");

      request.getSession().setAttribute("AWF", "Literatureintrag erfassen");
      request.getSession().setAttribute("AA", "Zeitschrift eingeben");

      return mapping.findForward(ZEITSCHRIFT);
    } 
}